# 运行Frida并测试
$logFile = "frida_output.txt"

Write-Host "`n开始Hook测试..." -ForegroundColor Green
Write-Host "输出将保存到: $logFile`n" -ForegroundColor Yellow

# 启动Frida并将输出重定向到文件
Start-Process powershell -ArgumentList "-Command", "cd D:\java\shumei-v4; frida -U -p 2586 -l hook_simple_test.js > frida_output.txt 2>&1" -NoNewWindow

Write-Host "等待Frida初始化（5秒）..." -ForegroundColor Cyan
Start-Sleep -Seconds 5

Write-Host "`n调用API..." -ForegroundColor Green
curl http://120.27.155.222:9999/api/message/send-test | Out-Null

Write-Host "等待Hook捕获（3秒）..." -ForegroundColor Cyan
Start-Sleep -Seconds 3

Write-Host "`n========== Frida输出 ==========`n" -ForegroundColor Yellow
if (Test-Path $logFile) {
    Get-Content $logFile
} else {
    Write-Host "日志文件不存在" -ForegroundColor Red
}

Write-Host "`n按任意键停止Frida..." -ForegroundColor Yellow
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

Get-Process | Where-Object {$_.ProcessName -like "*frida*"} | Stop-Process -Force
Write-Host "已停止" -ForegroundColor Green


